package com.ubs.persistence.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.*;

/**
 * The persistent class for the account database table.
 * 
 */
@Entity
@Table(name = "account")
@NamedQueries({
		@NamedQuery(name = "AccountEntity.selectByLoginPassword", query = "SELECT a FROM AccountEntity a "
				+ "WHERE a.login = :login " + "  AND a.password = :password"),

		@NamedQuery(name = "AccountEntity.isLoginExists", query = "SELECT count(a) FROM AccountEntity a "
				+ "WHERE a.login = :login"),

		@NamedQuery(name = "AccountEntity.updateBalance", query = "UPDATE AccountEntity a SET a.balance = a.balance + :delta "
				+ "WHERE a.id = :accountId")

})
public class AccountEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(unique = true, nullable = false)
	private int id;

	@Column(nullable = false, length = 255)
	private String login;

	@Column(nullable = false, length = 1024)
	private String password;

	@Column(name = "first_name", length = 100, nullable = false)
	private String firstName;

	@Column(name = "last_name", length = 100, nullable = false)
	private String lastName;

	@Column(name = "phone_number", length = 20, nullable = true)
	private String phoneNumber;

	@Column(name = "email", length = 100, nullable = false)
	private String email;

	@Column(nullable = false, length = 1)
	private String enabled;

	@OneToMany(mappedBy = "account")
	private Set<AccountServiceEntity> accountServices;

	@Column(nullable = false)
	private float balance;

	@Column(nullable = false, length = 1, name = "test_account")
	private String testAccount;

	@Column(name = "created_date", nullable = false)
	private Date createdDate;

	@Column(name = "confirmed_date")
	private Date confirmedDate;

	@Column(name = "last_login_date")
	private Date lastLoginDate;

	public AccountEntity() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setTestAccount(String testAccount) {
		this.testAccount = testAccount;
	}

	public String getTestAccount() {
		return testAccount;
	}

	public void setEnabled(String enabled) {
		this.enabled = enabled;
	}

	public String getEnabled() {
		return enabled;
	}

	public void setBalance(float balance) {
		this.balance = balance;
	}

	public float getBalance() {
		return balance;
	}

	public void setAccountServices(Set<AccountServiceEntity> accountServices) {
		this.accountServices = accountServices;
	}

	public Set<AccountServiceEntity> getAccountServices() {
		return accountServices;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setConfirmedDate(Date confirmedDate) {
		this.confirmedDate = confirmedDate;
	}

	public Date getConfirmedDate() {
		return confirmedDate;
	}

	public void setLastLoginDate(Date lastLoginDate) {
		this.lastLoginDate = lastLoginDate;
	}

	public Date getLastLoginDate() {
		return lastLoginDate;
	}
}